import {_decorator, Component, SpriteAtlas, SpriteFrame} from "cc";

const {ccclass, property} = _decorator;

@ccclass('RandomMapAssets')
export class RandomMapAssets extends Component {

    @property(SpriteAtlas)
    worldAssetAtlas!: SpriteAtlas;

    @property(SpriteAtlas)
    ceilAtlas!: SpriteAtlas;

    start() {

    }

    randomCeil(): SpriteFrame {
        const spriteFrames = this.ceilAtlas.getSpriteFrames()
        const randomIndex = Math.floor(Math.random() * spriteFrames.length);
        return spriteFrames[randomIndex]!;
    }

    randomWorldAssets(): SpriteFrame {
        const spriteFrames = this.worldAssetAtlas.getSpriteFrames()
        const randomIndex = Math.floor(Math.random() * spriteFrames.length);
        return spriteFrames[randomIndex]!;
    }
}